﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBControl;
using System.Data.SqlClient;
using System.Collections;

namespace SellerProject
{
    public partial class sellgoodCid : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getTotalCount();
                bindRepeater();
            }
        }

        protected void repPager_PageChanged(object sender, EventArgs e)
        {
            bindRepeater();
            ScriptManager.RegisterStartupScript(repPager, this.GetType(), "resizeimg", "<script>ResizeImg();</script>", false);
        }
        private void getTotalCount()
        {
            SqlDbHelper sdh = new SqlDbHelper();
            string sqlcount = "SELECT COUNT(*) FROM BuyersinfoR WHERE Status = 0";
            this.repPager.RecordCount = int.Parse(sdh.ExecuteScalar(sqlcount).ToString());
        }

        private void bindRepeater()
        {
            ItopInit iinit = new ItopInit();
            long curCid = 0;
            curCid = iinit.shopCatGet(Session["usNick"].ToString());
            SqlDbHelper sdh = new SqlDbHelper();
            string sqlwhere = " where [Status] = 0";
            if (curCid != 0)
            {
                sqlwhere += " and [Parentcateid] = " + curCid;
            }
            sqlwhere += " and [rsn] <> '" + Session["usNick"].ToString() + "'";
            SqlParameter p1 = new SqlParameter("@tablename", "GetDateByUser");//视图名或表名
            SqlParameter p2 = new SqlParameter("@pagerow", this.repPager.PageSize);         //每页显示记录数 
            SqlParameter p3 = new SqlParameter("@pagenow", this.repPager.CurrentPageIndex); //当前显示第几页 
            SqlParameter p4 = new SqlParameter("@ordercol", "Starttime");//排序字段
            SqlParameter p5 = new SqlParameter("@order", 1);//排序顺序，0升序，1降序
            SqlParameter p6 = new SqlParameter("@where", sqlwhere);
            SqlParameter[] paras = new SqlParameter[] { p1, p2, p3, p4, p5, p6 };
            this.binfoRepeater.DataSource = sdh.ExecuteDataTable("sp_page", System.Data.CommandType.StoredProcedure, null, paras);
            binfoRepeater.DataBind();
        }
    }
}